<h1>DefineImage</h1>

<p>DefineImage2 is used to define a transparent image compressed using the lossless 
zlib compression algorithm. The class supports colour-mapped images where the image data contains an index into a colour table or images where the image data specifies the colour directly. It 
extends DefineImage by including alpha channel information for the colour table and pixels in the image.</p>

<p>For colour-mapped images the colour table contains up to 256, 32-bit colours. The image contains one byte for each pixel which is an index into the table to specify the colour for that pixel. The colour table and the image data are compressed as a single block, with the colour table placed before the image.</p>

<p>For images where the colour is specified directly, the image data contains 32 bit colour values.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">10</td>
<td>Identifies the DefineImage2 instruction when it is encoded. It is encoded 
with the length field as a 16-bit integer (Little-endian byte order).</td>
</tr>

<tr>
<td nowrap valign="top">length</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">6</td>
<td>The length in bytes of the body of the instruction when it is encoded. If the length is greater 
than 62 then this field is set to 0x3F and the length is encoded using the 
extendedLength field. Encoded with the type field as a 16-bit integer.</td>
</tr>

<tr>
<td nowrap valign="top">extendedLength</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>Optional. Contains the length in bytes of the encoded instruction if it is
greater than 62 bytes. If the length is 62 bytes or less then this field is 
omitted.</td>
</tr>

<tr>
<td nowrap valign="top">identifier</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The unique identifier for this image definition. This is used when adding or removing 
the shape from the display list or when the shape is used as part of another 
object such as a button.</td>
</tr>

<tr>
<td nowrap valign="top">format</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The type of image encoded: 3 == 8-bit colour-mapped image and 5 == 32-bits 
per pixel RGBA image.</td>
</tr>

<tr>
<td nowrap valign="top">width</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Width of the image in pixels, NOT twips. 1 pixel = 20 twips.</td>
</tr>

<tr>
<td nowrap valign="top">height</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>Height of the image in pixels, NOT twips.  1 pixel = 20 twips.</td>
</tr>

<tr>
<td nowrap valign="top">tableSize</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of entries in the colour table - which is compressed as part of 
the image. Each entry in the colour table contains one byte each for the red, 
green and blue colour channels. The colour table is only used for indexed colour 
images. The table is not used when the colour is specified directly in each 
pixel. Only applies to images where format = 3.</td>
</tr>

<tr>
<td nowrap valign="top">compressedData</td>
<td nowrap valign="top">byte[n]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of bytes containing the zlib compressed colour table and image.</td>
</tr>

</table>

<p>The image data is stored in zlib compressed form within the object. For colour-mapped images the compressed data contains the colour table followed by the image data.</p>

<h2>History</h2>

<p>DefineImage2 represents the DefineBitsLossless2 tag from the Macromedia Flash 
(SWF) File Format Specification. It was introduced in Flash 3.</p>
